﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Fixx.Connector;

namespace FixxVS
{
	public partial class CacheSettings : UserControl
	{
		public delegate void CacheChangedHandler(object sender, CacheSettingsChangeArgs ca);
		public event CacheChangedHandler Change = delegate { };

		public CacheSettings()
		{
			InitializeComponent();
		}
		private void ThrowChangedEvent()
		{
			FixxRepositoryCache cacheItems = FixxRepositoryCache.None;
			if (this.cbClearUsers.Checked)
				cacheItems |= FixxRepositoryCache.Users;
			if (this.cbPriorities.Checked)
				cacheItems |= FixxRepositoryCache.Priorities;
			if (this.cbProjectMetaData.Checked)
				cacheItems |= FixxRepositoryCache.ProjectData;
			if (this.cbProjects.Checked)
				cacheItems |= FixxRepositoryCache.ProjectList;

			this.Change(this, new CacheSettingsChangeArgs()
			{
				CacheItems = cacheItems
			});
		}
		private void cbClearUsers_CheckedChanged(object sender, EventArgs e)
		{
			this.ThrowChangedEvent();
		}
	}
}
